<template>
  <div>

    <div class="form">
      <div class="hospSet">添加医院设置</div>
      <el-form ref="form"  :model="hospitalSet" label-width="100px">

        <el-form-item  label="医院名称" prop="hosname" :rules="[{ required: true, message: '请输入医院名称', trigger: 'blur' }]">
          <el-input v-model="hospitalSet.hosname" placeholder="医院名称"/>
        </el-form-item>
        <el-form-item style="margin-top: 50px" label="医院编号" prop="hoscode" :rules="[{ required: true, message: '请输入医院编号', trigger: 'blur' }]">
          <el-input  v-model="hospitalSet.hoscode" placeholder="医院编号"/>
        </el-form-item>
        <el-form-item style="margin-top: 50px" label="api基础路径" prop="apiUrl" :rules="[{ required: true, message: '请输入api基础路径', trigger: 'blur' }]">
          <el-input  v-model="hospitalSet.apiUrl" placeholder="api基础路径"/>
        </el-form-item>
        <el-form-item style="margin-top: 50px" label="联系人名称" prop="contactsName" :rules="[{ required: true, message: '请输入联系人名称', trigger: 'blur' }]">
          <el-input  v-model="hospitalSet.contactsName" placeholder="联系人名称"/>
        </el-form-item>
        <el-form-item style="margin-top: 50px" label="联系人手机" prop="contactsPhone"
                      :rules="[{ required: true, message: '请输入联系人电话', trigger: 'blur' }, { type: 'number', message: '联系人电话必须为数字值', trigger: ['blur', 'change'] }]">
          <el-input  v-model.number="hospitalSet.contactsPhone" placeholder="联系人手机"/>
        </el-form-item>
      </el-form>
    </div>
    <div class="button">
      <label class="btn btn-info active" style="margin-right:100px;">
        <el-button type="primary" @click="addHospSet">立即创建</el-button>
      </label>
      <label class="btn btn-info">
        <el-button @click="hospitalSet={}">重置</el-button>
      </label>
    </div>
  </div>
</template>

<script>
import hospSet from '@/api/hospSet'
export default {
  name: 'Add',
  data(){
    return{
      hospitalSet:{}
    }
  },
  methods:{
    //增加医院设置信息
    addHospSet(){
      hospSet.addHostSet(this.hospitalSet)
        .then(request =>{
          if(request.code ===200 && request.message ==='成功') {
            this.$message({
              message: '恭喜你，添加成功，请到医院设置列表中查看',
              type: 'success'
            });
            this.hospitalSet={}
          }
        })
        .catch(error =>{
          this.$message.error('抱歉，添加医院设置信息失败，请与IT管理员联系');
        })
    }
  },
  created() {
  }
}
</script>

<style scoped>
.form{
  width: 60%;
  text-align:center;
  margin:0 auto;
  line-height: 150px;
}
.hospSet{
  color: #000000;
  font-family: "Helvetica Neue",serif;
  font-size: 30px;
  line-height: 150px;
  text-align: center;
}
.button{
  margin-top: 20px;
  text-align:center;
  line-height: 150px;
}
</style>
